<?php
$form = $this->beginWidget('PsActiveForm', array(
	'id' => 'add-payment-voucher-form',
	'enableAjaxValidation' => false,
	'enableClientValidation' => true,
	'clientOptions' => array(
		'validationDelay' => 200,
		'inputContainer' => 'tr',
		'validateOnSubmit' => true,
		'validateOnChange' => false,
	)
		));
?>
<script type="text/javascript">
	var currency_code = "<?php echo (isset($paymentVoucher->currency_code) ? $paymentVoucher->currency_code : '$'); ?>";
</script>

<div id="addPaymentVoucher" class="">
	<div class="grid_16">
		<div class="section">
			<div class="block">
				<h2>Payment Voucher #<?php echo $paymentVoucher->payment_number; ?></h2>
				<div class="table-block">
					<table class="form-table">
						<tr>
							<th scope="row" width="170">
								<?php echo $form->labelEx($paymentVoucher, 'payee_name'); ?>
							</th>
							<td>
								<?php echo $form->textField($paymentVoucher, 'payee_name', array('size' => 45)); ?>
								<?php echo $form->hiddenField($paymentVoucher, 'payee_party_id'); ?>
								<?php echo $form->hiddenField($paymentVoucher, 'payable_item_ids'); ?>
							</td>
							<th scope="row" width="170">
								<?php echo $form->labelEx($paymentVoucher, 'payment_number', array('label' => 'Payment Voucher No')); ?>
							</th>
							<td>
								<?php echo $form->textField($paymentVoucher, 'payment_number', array('readonly' => ($this->action->id != 'create') ? 'readonly' : '')); ?>
								<?php if ($this->action->id == 'create'): ?>
									<?php echo $form->checkBox($paymentVoucher, 'automatic_numbering', array('uncheckValue' => 0)); ?>
									<?php
									echo $form->labelEx($paymentVoucher, 'automatic_numbering', array(
										'class' => 'tooltip-top',
										'title' => 'Automatically assign the next available number if the receipt number is taken',
										'label' => 'Automatic'
									));
									?>
								<?php endif; ?>
								<?php echo $form->error($paymentVoucher, 'payment_number'); ?>
							</td>
						</tr>
						<tr>
							<th scope="row" width="170">
								<?php echo $form->labelEx($paymentVoucher, 'amount'); ?>
							</th>
							<td>
								<?php
								$this->widget('common.widgets.PsAutoNumeric.PsAutoNumeric', array(
									'model' => $paymentVoucher,
									'attribute' => 'amount',
									'htmlOptions' => array(
										'disabled' => true
									),
									'options' => array(
										'vMax' => '999999999.99'
									)
								));
								?>
								<?php echo $form->hiddenField($paymentVoucher, 'amount'); ?>
							</td>
							<th scope="row" width="170">
								<?php echo $form->labelEx($paymentVoucher, 'payment_date', array('label' => 'Payment Voucher Date')); ?>
							</th>
							<td>
								<?php
								$form->widget('PsJuiDatePicker', array(
									'model' => $paymentVoucher,
									'attribute' => 'payment_date',
									'options' => array(
										'showButtonPanel' => false,
										'changeYear' => true,
										'dateFormat' => 'dd-mm-yy',
									),
								));
								?>
								<?php echo $form->error($paymentVoucher, 'payment_date'); ?>
							</td>
						</tr>
						<tr>
							<th scope="row" width="170">
								<?php echo $form->labelEx($paymentVoucher, 'payment_method_type_code', array('label' => 'Payment Method')); ?>
							</th>
							<td>
								<?php
								echo $form->dropDownList($paymentVoucher, 'payment_method_type_code', PaymentMethodType::getListData(), array(
									'prompt' => '[Select]',
								));
								?>
								<?php echo $form->error($paymentVoucher, 'payment_method_type_code'); ?>
							</td>
							<th scope="row" width="170">
								<?php echo $form->labelEx($paymentVoucher, 'issued_date'); ?>
							</th>
							<td>
								<?php
								$form->widget('PsJuiDatePicker', array(
									'model' => $paymentVoucher,
									'attribute' => 'issued_date',
									'options' => array(
										'showButtonPanel' => false,
										'changeYear' => true,
										'dateFormat' => 'dd-mm-yy',
									),
								));
								?>
								<?php echo $form->error($paymentVoucher, 'issued_date'); ?>
							</td>
						</tr>
						<tr>
							<th scope="row" width="170">
								<?php echo $form->labelEx($paymentVoucher, 'payment_ref_no', array('label' => 'Payment Method Ref No')); ?>
							</th>
							<td>
								<?php echo $form->textField($paymentVoucher, 'payment_ref_no'); ?>
								<?php echo $form->error($paymentVoucher, 'payment_ref_no'); ?>
							</td>
							<th scope="row" width="120"><?php echo $form->labelEx($paymentVoucher, 'currency_code'); ?></th>
							<td>
								<?php echo $form->dropDownList($paymentVoucher, 'currency_code', array('SGD' => 'SGD - Singapore Dollar')); ?>
								<?php echo $form->error($paymentVoucher, 'currency_code', false); ?>
							</td>
						</tr>
						<tr>
							<th scope="row" width="170">
								<?php echo $form->labelEx($paymentVoucher, 'comment'); ?>
							</th>
							<td>
								<?php echo $form->textField($paymentVoucher, 'comment', array('size' => 45)); ?>
								<?php echo $form->error($paymentVoucher, 'comment'); ?>
							</td>
							<th scope="row" width="170"></th>
							<td></td>
						</tr>
						<tr>
							<th scope="row" width="170">
								<?php echo $form->labelEx($paymentVoucher, 'for_external_invoice_number'); ?>
							</th>
							<td>
								<?php echo $form->textField($paymentVoucher, 'for_external_invoice_number', array('size' => 45)); ?>
								<?php echo $form->error($paymentVoucher, 'for_external_invoice_number'); ?>
							</td>
							<th scope="row" width="170"></th>
							<td></td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="grid_16 relative">
	<button type="submit" class="link-button green no-margin with-icon" id="btnFinish">
		<span>Save Payment Voucher</span>
	</button>
	&nbsp;or <a class="link" href="<?php echo $this->createUrl('paymentVoucher/index'); ?>">Cancel</a>
</div>
<?php $this->endWidget(); ?>